<?php

use yii\db\Migration;

class m180619_074027_alter_lesson_students extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->addColumn('{{%lesson_students}}', 't_all_fource', $this->text()->defaultValue(null)->comment('一键课下练习重点'));
            $this->addColumn('{{%lesson_students}}', 't_all_content', $this->text()->defaultValue(null)->comment('一键本课内容'));
            $this->addColumn('{{%lesson_students}}', 't_all_score', $this->integer(11)->defaultValue(null)->comment('一键本课评分'));
        }

    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropColumn('{{%lesson_students}}', 't_all_fource');
            $this->dropColumn('{{%lesson_students}}', 't_all_content');
            $this->dropColumn('{{%lesson_students}}', 't_all_score');
        }
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m180619_074027_alter_lesson_students cannot be reverted.\n";

        return false;
    }
    */
}
